package com.lesshassles.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.lesshassles.util.ApplicationSecurityManagerImpl;
import com.lesshassles.util.ApplicationSecurityManager;

/**
 * Controller for "signing out" of the application.
 * 
 * @author David Santoro
 */
public class SignOutController implements Controller {
	private ApplicationSecurityManager applicationSecurityManager;
	private String successView;

	/**
	 * Removes User object from session using ApplicationSecurityManager.
	 * 
	 * @see ApplicationSecurityManagerImpl
	 */
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		applicationSecurityManager.removeUser(request);
		return new ModelAndView(getSuccessView());
	}

	public ApplicationSecurityManager getApplicationSecurityManager() {
		return applicationSecurityManager;
	}

	public void setApplicationSecurityManager(ApplicationSecurityManager applicationSecurityManager) {
		this.applicationSecurityManager = applicationSecurityManager;
	}

	public String getSuccessView() {
		return successView;
	}

	public void setSuccessView(String successView) {
		this.successView = successView;
	}
}
